- /* sdfatanh.cpp by K.Tsuru */
- // function ID 3311 DRADIX
- /*************************************************************************
- SDouble class
- inverse hyperbolic artanh x(area tanh) defined by
- artanh x = (1/2)*log( (1+x)/(1-x) ) (|x|<1.0)
- When |x| is very near to 1.0 a large error causes
- in this case series expansion
- atanh(x) = (1/2)*log( (1+x)/(1-x) ) = x + x^3/3+x^5/5 + ...
- must be used. See AtanhSeries(x)
- *************************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* const func = "Atanh";
- #define usesAtanhSeriesInAtanh 0
- // for test. =1(use) 76.5sec(very slow), =0(no use) 13.4sec when 10,000 eff figs
- SDouble Atanh(const SDouble& x){
- if(x.Sign(3311) == 0) return 0.0;
- #if usesAtanhSeriesInAtanh
- if(x.NetRdxExp() < 0) return AtanhSeries(x); // |x| <1/DRADIX
- uint fig = x.Last() - x.First() + 1u;
- if(fig <= 4){ // short and small
- double xd = fabs(doubleD(x, 0));
- if(xd < 0.15) return AtanhSeries(x); // |x| < 0.15
- }
- #endif
- SDouble X(Dabs(x)), r; // X > 0
- r = ONE - X;
- if(r.Sign(3311) <= 0 || r.IsMLT(ONE)) x.SetError(x.DOMAIN_ERR, func, 3311); // x >= 1.0
- // here r > 0
- r = (ONE + X)/r; // > 0
- r = Log(r);
- r = DsDiv(r, 2);
-
- return x.Sign(3311) > 0 ? r : -r;
- }
sdfatanh.cpp : last modifiled at 2016/08/29 16:49:53(1,302 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).